package main

import (
	"blog/app/models"
	"blog/utils"
	"encoding/json"
	"fmt"
	"time"
)

var jsonData = `[
   {
       "ProjectId": "38d97f94-2aac-4cd0-8ee8-2a536d13f57c",
       "ProjectName": "大铲湾企鹅公寓05项目",
       "RegionName": "深圳",
       "RegionId": "eb557454-acc7-477b-810c-67168f61344d",
       "BizScene": "Price",
       "Index": 0,
       "NodeId": "f614f2f1-8bf0-4ac3-a8b6-9abaed9484c3",
       "NodeName": "业务leader审批",
       "NodeOrder": 1,
       "NodeApproverEnname": "boneyxiang",
       "NodeApproverCnname": "向阳",
       "Status": 1
   },
   {
       "ProjectId": "38d97f94-2aac-4cd0-8ee8-2a536d13f57c",
       "ProjectName": "大铲湾企鹅公寓05项目",
       "RegionName": "深圳",
       "RegionId": "eb557454-acc7-477b-810c-67168f61344d",
       "BizScene": "Price",
       "Index": 0,
       "NodeId": "7b87c2aa-afb3-4466-b97c-bf507c35660f",
       "NodeName": "财管leader审批",
       "NodeOrder": 2,
       "NodeApproverEnname": "jeremyyou",
       "NodeApproverCnname": "游俊杰",
       "Status": 1
   },
   {
       "ProjectId": "38d97f94-2aac-4cd0-8ee8-2a536d13f57c",
       "ProjectName": "大铲湾企鹅公寓05项目",
       "RegionName": "深圳",
       "RegionId": "eb557454-acc7-477b-810c-67168f61344d",
       "BizScene": "Price",
       "Index": 0,
       "NodeId": "f614f2f1-8bf0-4ac3-a8b6-9abaed9484c3",
       "NodeName": "业务leader审批",
       "NodeOrder": 1,
       "NodeApproverEnname": "yeahxu",
       "NodeApproverCnname": "许蒙",
       "Status": 1
   },
   {
       "ProjectId": "38d97f94-2aac-4cd0-8ee8-2a536d13f57c",
       "ProjectName": "大铲湾企鹅公寓05项目",
       "RegionName": "深圳",
       "RegionId": "eb557454-acc7-477b-810c-67168f61344d",
       "BizScene": "PriceDiscount",
       "Index": 0,
       "NodeId": "9dd580db-dfd3-49f0-8950-345d4eba2f56",
       "NodeName": "业务leader审批",
       "NodeOrder": 1,
       "NodeApproverEnname": "boneyxiang",
       "NodeApproverCnname": "向阳",
       "Status": 1
   },
   {
       "ProjectId": "38d97f94-2aac-4cd0-8ee8-2a536d13f57c",
       "ProjectName": "大铲湾企鹅公寓05项目",
       "RegionName": "深圳",
       "RegionId": "eb557454-acc7-477b-810c-67168f61344d",
       "BizScene": "PriceDiscount",
       "Index": 0,
       "NodeId": "9dd580db-dfd3-49f0-8950-345d4eba2f56",
       "NodeName": "业务leader审批",
       "NodeOrder": 1,
       "NodeApproverEnname": "liviapeng",
       "NodeApproverCnname": "彭慧琳",
       "Status": 1
   },
   {
       "ProjectId": "38d97f94-2aac-4cd0-8ee8-2a536d13f57c",
       "ProjectName": "大铲湾企鹅公05项目",
       "RegionName": "深圳",
       "RegionId": "eb557454-acc7-477b-810c-67168f61344d",
       "BizScene": "PriceDiscount",
       "Index": 0,
       "NodeId": "38de978a-0c9c-46e8-8b9a-3e3ef30af7e2",
       "NodeName": "财管leader审批",
       "NodeOrder": 2,
       "NodeApproverEnname": "jeremyyou",
       "NodeApproverCnname": "游俊杰",
       "Status": 1
   },
   {
       "ProjectId": "38d97f94-2aac c-4cd0-8ee8-2a536d13f57c",
       "ProjectName": "大铲湾企鹅公寓05项目",
       "RegionName": "深圳",
       "RegionId": "eb557454-acc7-477b-810c-67168f61344d",
       "BizScene": "PriceDiscount",
       "Index": 0,
       "NodeId": "38de978a-0c9c-46e8-8b9a-3e3ef30af7e2",
       "NodeName": "财管leader审批",
       "NodeOrder": 2,
       "NodeApproverEnname": "yeahxu",
       "NodeApproverCnname": "许蒙",
       "Status": 1
   }
]`

//func main() {
//	var arr = [5]int{1, 2, 3, 4, 5}
//	for _, item := range arr {
//		fmt.Println(item)
//		if item > 3 {
//			break
//		}
//	}
//}

func main() {
	utils.InitConfig()
	utils.InitMysql()

	//sss := models.UserBasic{
	//	UserName:      "faddd",
	//	Password:      "fad",
	//	Phone:         "fda",
	//	Email:         "fa",
	//	Identity:      "fadsd",
	//	ClientIP:      "fsad",
	//	ClientPort:    "dfa",
	//	LoginTime:     time.Now(),
	//	HeartbeatTime: time.Now(),
	//	LogOutTime:    time.Now(),
	//	IsLogout:      false,
	//}
	//
	//kk := utils.MySqlDB.Create(&sss)
	//fmt.Println("吸入", kk)
	//fmt.Println("吸入------", sss.ID)

	sss2 := models.UserBasic{
		ID:            5,
		UserName:      "333",
		Password:      "fad",
		Phone:         "fddddddda",
		Email:         "fa",
		Identity:      "fadsd",
		ClientIP:      "fsad",
		ClientPort:    "dfa",
		LoginTime:     time.Now(),
		HeartbeatTime: time.Now(),
		LogOutTime:    time.Now(),
		IsLogout:      false,
	}

	kk2 := utils.MySqlDB.Debug().Save(&sss2).Error
	fmt.Println("查看错误", kk2)

	//utils.InitRedis()
	//router.Router()
}

func main2() {
	//service.OpeExcelData() // 测试账单读写
	//utils.InitConfig()
	//utils.InitMysql()
	//service.AddUser()
	//service.AllRun()
}

// GetApprovalWorkflowConfigData 请求获取审批配置的列表页面返回结果
type GetApprovalWorkflowConfigData struct {
	ProjectId          string
	ProjectName        string
	RegionName         string
	RegionId           string
	BizScene           string
	Index              int32
	NodeId             string
	NodeName           string
	NodeOrder          int32
	NodeApproverEnname string
	NodeApproverCnname string
	Status             int32
}

type ApprovalWorkflowsNodeApprovers struct {
	NodeApproverEnname string `protobuf:"bytes,1,opt,name=node_approver_enname,json=nodeApproverEnname,proto3" json:"node_approver_enname,omitempty"`
	NodeApproverCnname string `protobuf:"bytes,2,opt,name=node_approver_cnname,json=nodeApproverCnname,proto3" json:"node_approver_cnname,omitempty"`
	Status             int32  `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"`
}

type ApprovalWorkflowsNodeList struct {
	NodeId        string                            `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
	NodeName      string                            `protobuf:"bytes,2,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
	NodeOrder     int32                             `protobuf:"varint,3,opt,name=node_order,json=nodeOrder,proto3" json:"node_order,omitempty"`
	NodeApprovers []*ApprovalWorkflowsNodeApprovers `protobuf:"bytes,4,rep,name=node_approvers,json=nodeApprovers,proto3" json:"node_approvers,omitempty"`
}

type ApprovalWorkflowsData struct {
	ProjectId   string                       `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"`
	ProjectName string                       `protobuf:"bytes,2,opt,name=project_name,json=projectName,proto3" json:"project_name,omitempty"`
	RegionName  string                       `protobuf:"bytes,3,opt,name=region_name,json=regionName,proto3" json:"region_name,omitempty"`
	RegionId    string                       `protobuf:"bytes,4,opt,name=region_id,json=regionId,proto3" json:"region_id,omitempty"`
	BizScene    string                       `protobuf:"bytes,5,opt,name=biz_scene,json=bizScene,proto3" json:"biz_scene,omitempty"`
	Index       int32                        `protobuf:"varint,6,opt,name=index,proto3" json:"index,omitempty"`
	NodeList    []*ApprovalWorkflowsNodeList `protobuf:"bytes,7,rep,name=node_list,json=nodeList,proto3" json:"node_list,omitempty"`
}

// 练习处理多级数组数据
func main55() {
	fmt.Println("练习处理多级数组数据")

	str := []byte(jsonData)

	var data []GetApprovalWorkflowConfigData

	err := json.Unmarshal(str, &data)
	if err != nil {
		fmt.Println(err)
	}
	//var NodeApprovers []*ApprovalWorkflowsNodeApprovers
	//var NodeList []*ApprovalWorkflowsNodeList
	//var DataList []*ApprovalWorkflowsData
	//
	approversList := make(map[string]ApprovalWorkflowsNodeApprovers)
	nodeList := make(map[string]ApprovalWorkflowsNodeList)
	dataList := make(map[string]ApprovalWorkflowsData)

	//approveList := make(map[string]ApprovalWorkflowsNodeApprovers)

	//for _, record := range data {
	//
	//}

	fmt.Println("--------------------------------------------------------------------------")
	fmt.Println(approversList, nodeList, dataList)
}

func main333() {
	fmt.Println("hello")
	fmt.Println(time.Now())
	fmt.Println(time.Now().Format("2006-01-02 15:04:05"))

}
